﻿/*
版权所有：版权所有(C) 2010，刘建新
文件编号：M01_Levelword.cs
文件名称：Levelword.cs
系统编号：Z0003007
系统名称：通用办公系统
模块编号：M01
模块名称：信息发布
设计文档：IOA_M01信息发布XDE建模.mdx
完成日期：2010/12/17
作　　者：
内容摘要：表[LevelWord]对应的实体类
*/

using System;
using System.Collections;
using System.Data;


namespace Eis51.CampanyCMS.Model.Bus
{
		/// <summary>
		/// 类 编 号：
		/// 类 名 称：Levelword
		/// 内容摘要：
		/// </summary>
		
		[Serializable]
		public class Levelword : BaseModel
		{
		#region 自动生成代码
		
			#region 重载Equals/GetHashCode
			/// <summary>
			/// 重载Equals			
			/// </summary>
			public override bool Equals (Object obj)
			{
				if (obj != null && obj is Levelword)
				{
					if (obj == this)
						return true;
					Levelword castObj = (Levelword)obj; 
					
					if (!this.m_Levelwordid.Equals(castObj.Levelwordid))
						return false;
						
					if (!this.m_Title.Equals(castObj.Title))
						return false;
						
					if (!this.m_Content.Equals(castObj.Content))
						return false;
						
					if (!this.m_Username.Equals(castObj.Username))
						return false;
						
					if (!this.m_Typename.Equals(castObj.Typename))
						return false;
						
					if (!this.m_Typevalue.Equals(castObj.Typevalue))
						return false;
						
					if (!this.m_State.Equals(castObj.State))
						return false;
						
					if (!this.m_Createdt.Equals(castObj.Createdt))
						return false;
						
					if (!this.m_Ipaddress.Equals(castObj.Ipaddress))
						return false;
						
					return true;
				}
				return false;
			}
			
			/// <summary>
			/// 重载GetHashCode
			/// </summary>
			public override int GetHashCode()
			{
					int hash = 0;					
					
					hash = hash <<  8;
					if ((object)m_Levelwordid != null)
					{
						hash = hash ^ m_Levelwordid.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Title != null)
					{
						hash = hash ^ m_Title.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Content != null)
					{
						hash = hash ^ m_Content.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Username != null)
					{
						hash = hash ^ m_Username.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Typename != null)
					{
						hash = hash ^ m_Typename.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Typevalue != null)
					{
						hash = hash ^ m_Typevalue.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_State != null)
					{
						hash = hash ^ m_State.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Createdt != null)
					{
						hash = hash ^ m_Createdt.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Ipaddress != null)
					{
						hash = hash ^ m_Ipaddress.GetHashCode();
					}
						
					return hash; 
			}
			#endregion
			
			public Levelword()
			{
				MarkNew();
			}						
			
			public Levelword GetOldValue()
			{
				return OldValue as Levelword;
			}
		
		#region Levelwordid属性
			private int m_Levelwordid = 0;
			/// <summary>
			/// 属性名称： Levelwordid
			/// 内容摘要： DB列名：LevelWordID[]
			///            DB类型：int
			/// </summary>
			public int Levelwordid
			{
				get
					{
						return m_Levelwordid;
					}
				set
					{
						if (m_Levelwordid as object == null || !m_Levelwordid.Equals(value))
						{
							m_Levelwordid = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Title属性
			private string m_Title = String.Empty;
			/// <summary>
			/// 属性名称： Title
			/// 内容摘要： DB列名：Title[]
			///            DB类型：string
			/// </summary>
			public string Title
			{
				get
					{
						return m_Title;
					}
				set
					{
						if (m_Title as object == null || !m_Title.Equals(value))
						{
							m_Title = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Content属性
			private string m_Content = String.Empty;
			/// <summary>
			/// 属性名称： Content
			/// 内容摘要： DB列名：Content[]
			///            DB类型：string
			/// </summary>
			public string Content
			{
				get
					{
						return m_Content;
					}
				set
					{
						if (m_Content as object == null || !m_Content.Equals(value))
						{
							m_Content = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Username属性
			private string m_Username = String.Empty;
			/// <summary>
			/// 属性名称： Username
			/// 内容摘要： DB列名：UserName[]
			///            DB类型：string
			/// </summary>
			public string Username
			{
				get
					{
						return m_Username;
					}
				set
					{
						if (m_Username as object == null || !m_Username.Equals(value))
						{
							m_Username = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Typename属性
			private string m_Typename = String.Empty;
			/// <summary>
			/// 属性名称： Typename
			/// 内容摘要： DB列名：TypeName[]
			///            DB类型：string
			/// </summary>
			public string Typename
			{
				get
					{
						return m_Typename;
					}
				set
					{
						if (m_Typename as object == null || !m_Typename.Equals(value))
						{
							m_Typename = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Typevalue属性
			private string m_Typevalue = String.Empty;
			/// <summary>
			/// 属性名称： Typevalue
			/// 内容摘要： DB列名：TypeValue[]
			///            DB类型：string
			/// </summary>
			public string Typevalue
			{
				get
					{
						return m_Typevalue;
					}
				set
					{
						if (m_Typevalue as object == null || !m_Typevalue.Equals(value))
						{
							m_Typevalue = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region State属性
			private int m_State = 0;
			/// <summary>
			/// 属性名称： State
			/// 内容摘要： DB列名：state[]
			///            DB类型：int
			/// </summary>
			public int State
			{
				get
					{
						return m_State;
					}
				set
					{
						if (m_State as object == null || !m_State.Equals(value))
						{
							m_State = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Createdt属性
			private DateTime m_Createdt = new DateTime(1900,1,1);
			/// <summary>
			/// 属性名称： Createdt
			/// 内容摘要： DB列名：CreateDt[]
			///            DB类型：DateTime
			/// </summary>
			public DateTime Createdt
			{
				get
					{
						return DateTime.Parse(m_Createdt.ToString("yyyy-MM-dd HH:mm:ss"));
					}
				set
					{
						if (m_Createdt as object == null || !m_Createdt.Equals(value))
						{
							m_Createdt = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Ipaddress属性
			private string m_Ipaddress = String.Empty;
			/// <summary>
			/// 属性名称： Ipaddress
			/// 内容摘要： DB列名：ipAddress[]
			///            DB类型：string
			/// </summary>
			public string Ipaddress
			{
				get
					{
						return m_Ipaddress;
					}
				set
					{
						if (m_Ipaddress as object == null || !m_Ipaddress.Equals(value))
						{
							m_Ipaddress = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region static CreateDataTable/FillDataRow/DataRow2Obj/Dt2Objs/FillDataTable
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="tableName">表名</param>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(string tableName,ColumnNameEnum cne)
			{
				DataTable dtResult = new DataTable(tableName);
			
				if (cne == ColumnNameEnum.DBName)
				{
					dtResult.Columns.Add(new DataColumn("LevelWordID",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Title",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Content",typeof(string)));
					dtResult.Columns.Add(new DataColumn("UserName",typeof(string)));
					dtResult.Columns.Add(new DataColumn("TypeName",typeof(string)));
					dtResult.Columns.Add(new DataColumn("TypeValue",typeof(string)));
					dtResult.Columns.Add(new DataColumn("state",typeof(int)));
					dtResult.Columns.Add(new DataColumn("CreateDt",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("ipAddress",typeof(string)));
				}
				else if (cne == ColumnNameEnum.PropertyName)
				{
					dtResult.Columns.Add(new DataColumn("Levelwordid",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Title",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Content",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Username",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Typename",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Typevalue",typeof(string)));
					dtResult.Columns.Add(new DataColumn("State",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Createdt",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("Ipaddress",typeof(string)));
				}
				return dtResult;
			}
			
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(ColumnNameEnum cne)
			{
				return CreateDataTable(null,cne);
			}

			/// <summary>
			/// 得到实体对应的DataTable(默认列名映射为属性名)
			/// </summary>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable()
			{
				return CreateDataTable(ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			public void FillDataRow(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				if (ColumnNameEnum.DBName == cne)
				{
					dr["LevelWordID"] = this.Levelwordid;
					dr["Title"] = this.Title;
					dr["Content"] = this.Content;
					dr["UserName"] = this.Username;
					dr["TypeName"] = this.Typename;
					dr["TypeValue"] = this.Typevalue;
					dr["state"] = this.State;
					dr["CreateDt"] = this.Createdt;
					dr["ipAddress"] = this.Ipaddress;
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					dr["Levelwordid"] = this.Levelwordid;
					dr["Title"] = this.Title;
					dr["Content"] = this.Content;
					dr["Username"] = this.Username;
					dr["Typename"] = this.Typename;
					dr["Typevalue"] = this.Typevalue;
					dr["State"] = this.State;
					dr["Createdt"] = this.Createdt;
					dr["Ipaddress"] = this.Ipaddress;					
				}
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow(默认列名映射为属性名)
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			public void FillDataRow(DataRow dr)
			{
				this.FillDataRow(dr,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 将DataRow转换成Levelword对象
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			/// <returns>Levelword对象</returns>
			public static Levelword Dr2Obj(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				Levelword obj = new Levelword();
				if (ColumnNameEnum.DBName == cne)
				{
					obj.Levelwordid = (dr["LevelWordID"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["LevelWordID"],typeof(int));
					obj.Title = (dr["Title"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Title"],typeof(string));
					obj.Content = (dr["Content"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Content"],typeof(string));
					obj.Username = (dr["UserName"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["UserName"],typeof(string));
					obj.Typename = (dr["TypeName"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["TypeName"],typeof(string));
					obj.Typevalue = (dr["TypeValue"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["TypeValue"],typeof(string));
					obj.State = (dr["state"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["state"],typeof(int));
					obj.Createdt = (dr["CreateDt"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["CreateDt"],typeof(DateTime));
					obj.Ipaddress = (dr["ipAddress"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["ipAddress"],typeof(string));
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					obj.Levelwordid = (dr["Levelwordid"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Levelwordid"],typeof(int));
					obj.Title = (dr["Title"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Title"],typeof(string));
					obj.Content = (dr["Content"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Content"],typeof(string));
					obj.Username = (dr["Username"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Username"],typeof(string));
					obj.Typename = (dr["Typename"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Typename"],typeof(string));
					obj.Typevalue = (dr["Typevalue"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Typevalue"],typeof(string));
					obj.State = (dr["State"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["State"],typeof(int));
					obj.Createdt = (dr["Createdt"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["Createdt"],typeof(DateTime));
					obj.Ipaddress = (dr["Ipaddress"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Ipaddress"],typeof(string));		
				}
				
				return obj;
			}
			
			/// <summary>
			/// 将DataRow转换成Levelword对象(默认列名映射为属性名)
			/// </summary>
			/// <returns>Levelword对象</returns>
			public static Levelword Dr2Obj(DataRow dr)
			{
				return Dr2Obj(dr,ColumnNameEnum.DBName);
			}
			
			/// <summary>
			/// 将DataTabe转换成的Levelword对象集合
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			/// <returns>Levelword对象的集合</returns>
			public static IList Dt2Objs(DataTable dt,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				
				ArrayList alResult = new ArrayList();
				
				foreach(DataRow dr in dt.Rows)
				{
					alResult.Add(Dr2Obj(dr,cne));
				}
				
				return alResult;
			}

			/// <summary>
			/// 将DataTabe转换成的Levelword对象集合(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <returns>Levelword对象的集合</returns>
			public static IList Dt2Objs(DataTable dt)
			{
				return Dt2Objs(dt,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用objs的Levelword对象集合填充DataTable
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">Levelword对象集合</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			public static void FillDataTable(DataTable dt,IList objs,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				if (objs == null)
				{
					throw new ArgumentNullException("objs");
				}
				
				foreach(Levelword obj in objs)
				{
					DataRow dr = dt.NewRow();
					obj.FillDataRow(dr,cne);
					dt.Rows.Add(dr);
				}
			}

			/// <summary>
			/// 用objs的Levelword对象集合填充DataTable(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">Levelword对象集合</param>
			public static void FillDataTable(DataTable dt,IList objs)
			{
				FillDataTable(dt,objs,ColumnNameEnum.PropertyName);
			}
		#endregion
		
		/// <summary>
		/// 取消编辑,恢复到上次有效调用BeginEdit前的状态,并清空保留值
		/// </summary>
		public override void CancelEdit()
		{
			Levelword old = this.OldValue as Levelword;
			if (old != null)
			{
					this.Levelwordid = old.Levelwordid;
					this.Title = old.Title;
					this.Content = old.Content;
					this.Username = old.Username;
					this.Typename = old.Typename;
					this.Typevalue = old.Typevalue;
					this.State = old.State;
					this.Createdt = old.Createdt;
					this.Ipaddress = old.Ipaddress;				
				this.OldValue = null;
			}
		}
		
		
		
		
		#region Levelword实体的内部Key类
			/// <summary>
			/// Levelword实体的Key类
			/// </summary>
			public sealed class Key
			{
		
				private int m_Levelwordid;
				public int Levelwordid
				{
 					get 
					{ 
						 return m_Levelwordid; 
					}
					set 
					{ 
						m_Levelwordid = value;
					}
				}
		
				public Key(int pLevelwordid)
				{
					m_Levelwordid=pLevelwordid;

				}
			}
		#endregion
			/// <summary>
			/// 得到实体Levelword的PK
			/// </summary>
			public Key GetKey()
			{
				return new Key(Levelwordid);				
			}
			
				
		#endregion
	}
}
